package com.squirrel.michale.test02;

import org.w3c.dom.Node;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime ${DATE} ${TIME}
 * @company Michale Squirrel
 * @link
 * @description
 */
public class Main {
     // main入口由OJ平台调用

    public static void main(String[] args) throws IOException {

        try (InputReader reader = new InputReader()) {

             int len = Integer.parseInt(reader.readStr());
            String[] strArr = reader.readStrArrFromNline(len);
            int depth = Integer.parseInt(reader.readStr());

            process(strArr, depth);

        }

    }

    static void process(String[] strArr, int depth) {
        var result = new Solution().logAnalysis(strArr, depth);
        System.out.println(result);
    }

 

    // 保证release的输入用例的格式正确，框架不做过度检查；如果本地联调输入不合法，直接抛异常，根据捕获异常进行定位；

    static class InputReader implements AutoCloseable {

        BufferedReader br = null;

        InputReader() {

            this.br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));

        }

 

        // 不单独提供readInt，直接 Integer.parseInt(reader.readStr()) 即可

        String readStr() throws IOException {

            return this.br.readLine().trim();

        }

        List<String> readLines() throws IOException {

            return this.br.lines()

                .collect(Collectors.toList());

        }

        String[] readStrArr(int num, String delimiter) throws IOException {

            if (num == 0) {

                return new String[]{};

            }

            String[] res = this.readStr().split(delimiter);

            if (num != -1 && num != res.length) {

                System.out.println("input error");

            }

            return res;

        }

        String[] readStrArrFromNline(int num) throws IOException {

            String[] strArr = new String[num];

            for (int i = 0; i < num; i++) {

                strArr[i] = this.readStr();

            }

            return strArr;

        }

        <R> List<R> readObjListFromNline(int num, Function<String, ? extends R> fromStr) throws IOException {

            List<R> list = new ArrayList<>(num);

            for (int i = 0; i < num; i++) {

                list.add(fromStr.apply(this.readStr()));

            }

            return list;

        }

        // 返回string[]的list样例，暂时不提供返回 String[][]

        // 如： List<String[]> list = this.readObjListFromNline(rows, (str) -> str.split(delimiter));

 

        int[][] readIntArr2Dim(int rows, String delimiter) throws IOException {

            int[][] matrix = new int[rows][];

            for (int i = 0; i < rows; i++) {

                matrix[i] = InputReader.map2IntArr(this.readStrArr(-1, delimiter));

            }

            return matrix;

        }

 

        // 如读取一行str作为int，可以：InputReader.map2IntArr(reader.readStrArr(-1, delimiter));

        static int[] map2IntArr(String[] strArr) throws IOException {

            return Arrays.stream(strArr)

                .mapToInt(Integer::parseInt).toArray();

        }

 

        @Override // try-resource自动释放资源

        public void close() throws IOException {

            this.br.close();

        }

    }
}